#include <iostream>
#include <math.h>
#include <vector>
#include <algorithm>
using namespace std;

int maxArea(vector<int>& height)
{
    int result=0;
    int i=0,j=height.size()-1;
    while(i<j){
        result=max(result,min(height[i],height[j])*(j-i));
        if(height[i]<=height[j])i++;
        else j--;
    }
    return result;
}


int main() {
    int b[9]={1,8,6,2,5,4,8,3,7};
    vector<int>a(b,b+9);
    cout<<maxArea(a)<<endl;
    return 0;
}